package o;

import com.huawei.appmarket.pkisign.zip.ZipFormatException;
import com.huawei.hms.aaid.constant.AaidIdConstant;
import java.io.IOException;
import java.nio.ByteOrder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;

public abstract class dly {
    static final /* synthetic */ boolean ˋ = (!dly.class.desiredAssertionStatus());

    public static dma<String, byte[]> ˋ(dmm o_dmm) throws IllegalArgumentException {
        try {
            int i = o_dmm.ॱ(16, 4).order(ByteOrder.LITTLE_ENDIAN).getInt();
            if (ˋ || i == 1896449818) {
                Object obj;
                switch (o_dmm.ॱ(40, 4).order(ByteOrder.LITTLE_ENDIAN).getInt()) {
                    case 257:
                        obj = AaidIdConstant.SIGNATURE_SHA256;
                        break;
                    case 258:
                        obj = "SHA-512";
                        break;
                    case 259:
                        obj = AaidIdConstant.SIGNATURE_SHA256;
                        break;
                    case 260:
                        obj = "SHA-512";
                        break;
                    case 513:
                        obj = AaidIdConstant.SIGNATURE_SHA256;
                        break;
                    case 514:
                        obj = "SHA-512";
                        break;
                    case 769:
                        obj = AaidIdConstant.SIGNATURE_SHA256;
                        break;
                    default:
                        throw new IllegalArgumentException("Unidentified signature algorithm in the first v2 signing block");
                }
                return dma.ˋ(obj, o_dmm.ॱ(48, o_dmm.ॱ(44, 4).order(ByteOrder.LITTLE_ENDIAN).getInt()).array());
            }
            throw new AssertionError();
        } catch (IOException e) {
            return null;
        }
    }

    public static byte[] ˊ(dmm o_dmm, long j, List<dmd> list) {
        String str = "META-INF/MANIFEST.MF";
        for (dmd o_dmd : list) {
            String ॱ = o_dmd.ॱ();
            if (ॱ.startsWith("META-INF/") && str.equals(ॱ)) {
                break;
            }
        }
        dmd o_dmd2 = null;
        if (o_dmd2 == null) {
            throw new IllegalArgumentException("Raise suitable exception, no manifest entry.");
        }
        try {
            byte[] ˋ = dmg.ˋ(o_dmm, o_dmd2, j);
            MessageDigest instance = MessageDigest.getInstance(AaidIdConstant.SIGNATURE_SHA256);
            instance.update(ˋ);
            return instance.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new InternalError("Algorithm SHA-256 is not supported by library");
        } catch (ZipFormatException e2) {
            throw new IllegalArgumentException("APK is not a valid zip file");
        } catch (IOException e3) {
            throw new IllegalArgumentException("Cannot access APK");
        }
    }
}
